package com.wocao.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wocao.entity.ResponseResult;
import com.wocao.entity.ZyRepair;
import com.wocao.service.ZyRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ZyRepairController {

    @Autowired
    private ZyRepairService zyRepairService;


    @GetMapping("/getRepair/{communityId}")
    public ResponseResult getRepair(@PathVariable Long communityId) {
        try {
            List<ZyRepair> list = zyRepairService.list(new QueryWrapper<ZyRepair>().eq("community_id", communityId));
            return ResponseResult.ok(list);
        } catch (Exception e) {
            return ResponseResult.error(500L, "查询失败");
        }
    }

    @PutMapping("/updateRepair")
    public ResponseResult updateRepair(@RequestBody ZyRepair zyRepair) {
        try {
            zyRepair.setRepairState("0");
            zyRepairService.updateById(zyRepair);
            return ResponseResult.ok("修改成功");
        } catch (Exception e) {
            return ResponseResult.error(500L, "修改失败");
        }
    }

}
